package com.vhall.component.entity.interactive.vo;

import com.alibaba.fastjson.annotation.JSONField;
import com.vhall.component.framework.common.annotation.ParamName;
import lombok.Data;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Pattern;
import java.io.Serializable;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;

/**
 * @author yuanzh
 * @date 2021/11/24
 */
@Data
public class QuestionAdmDeleteReqVO implements Serializable {

    private static final long serialVersionUID = 7692204761675668301L;

    /**
     * 挂件id，多个用逗号相隔
     */
    @NotBlank(message = "参数不允许为空")
    @ParamName("question_ids")
    @Pattern(regexp = "^(?!,)[\\d,]*(?<!,)$", message = "参数错误，请传入正确的格式")
    private String questionIds;

    /**
     * 获取问卷id集合
     *
     * @return 问卷ids
     */
    @JSONField(serialize = false)
    public Set<String> getQuestionIds() {
        String[] arr = questionIds.split(",");
        return new HashSet<>(Arrays.asList(arr));
    }
}
